<?php
/**
 * Created by PhpStorm.
 * User: liuxiaojie
 * Date: 2019-03-10
 * Time: 22:51
 */

namespace app\ops\controller;

class Service extends Base

{

    function index()
    {
        $list = db('service_config')->where(['status'=> 1])->select();

        $this->assign('list', $list);
        return $this->fetch();
    }

    function edit($id = 0)
    {
        $post = request()->post();
        if($post)
        {
            if($post['id'])
            {
                db('service_config')->update(['id'=> $post['id'], 'icon'=> $post['icon'], 'name'=> $post['name'], 'commission'=> $post['commission'], 'earnest_money'=> $post['earnest_money'], 'terrace_money'=> $post['terrace_money'], 'description'=> $post['description'], 'diam'=> $post['diam'], 'tiger_tee'=> $post['tiger_tee'], 'image'=> $post['image'], 'fees_desc'=> $post['fees_desc']]);
            }else{
                db('service_config')->insert(['icon'=> $post['icon'], 'name'=> $post['name'],'commission'=> $post['commission'], 'earnest_money'=> $post['earnest_money'], 'terrace_money'=> $post['terrace_money'], 'description'=> $post['description'], 'diam'=> $post['diam'], 'tiger_tee'=> $post['tiger_tee'], 'image'=> $post['image'], 'fees_desc'=> $post['fees_desc']]);
            }
            return success([]);
        }else{
            $data = db('service_config')->where(['id'=> $id])->find();
            $this->assign('data', $data);
            return $this->fetch();
        }
    }


}